<template>
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="false">
			<block slot="content">首页</block>
		</cu-custom>
		
		<add-tip :tip="tip" :duration="duration"/>

		<!-- banner图 -->
		<view class="uni-padding-wrap">
			<view class="page-section swiper">
				<view class="page-section-spacing">
					<swiper class="swiper" circular="true" indicator-dots="true" autoplay="true" interval="3500" duration="600">
						<swiper-item class="swiper-list" v-for="(item, index) in bannerList" :key="index">
							<view class="swiper-item uni-bg-red">
								<image class="swiper-img" :src="item.imageUrl" mode=""></image>
							</view>
						</swiper-item>
					</swiper>
				</view>
			</view>
		</view>
		
		<!-- 导航栏 -->
	<!-- 	<view class="cu-list grid solids-bottom col-4 no-border">
			<view class="cu-item" v-for="(item,index) in categories" :key="index" :style="[{animation: 'show ' + ((index+1)*0.2+1) + 's 1'}]"
			 @click="goCategorieslist" :data-mid="item.mid">
				<view :class="['cuIcon-' + item.cuIcon,'text-' + item.color]">
					<view class="cu-tag badge" v-if="item.count!=0">
						<block v-if="item.badge!=1">{{item.badge>99?'99+':item.badge}}</block>
					</view>
				</view> 
				<text>{{item.name}}</text>
			</view>
		</view> -->
		
		<!-- 心理干预 -->
		<view class="cu-bar bg-white margin-top-xs">
			<view class="action sub-title">
				<text class="text-xl text-bold text-blue text-shadow">心理干预</text>
				<text class="text-ABC text-blue">advice</text>
			</view>
		<!-- 	<view class="action" @click="goAdvice">
				<text class="text-lg text-grey text-shadow">更多</text>
			</view> -->
		</view>

		<view class="skill-sequence-panel-content-wrapper">
			<!--左边虚化-->
			<view class="hide-content-box hide-content-box-left"></view>
			<!--右边虚化-->
			<view class="hide-content-box hide-content-box-right"></view>
			<scroll-view scroll-x="true" class="kite-classify-scroll">
				<view class="kite-classify-cell shadow">
					<view class="nav-li bg-index2">
						<view class="nav-name">心理量表评估</view>
					</view>
					<view class="nav-content">识别情绪障碍，测量压力水平，评估个人发展。</view>
					<view @click="goLB" class="nav-btn shadow bg-index2">进入</view>
				</view>
				<view class="kite-classify-cell shadow">
					<view class="nav-li bg-index2">
						<view class="nav-name">正念疗法</view>
					</view>
					<view class="nav-content">通过培养当下意识来减缓压力，改善情绪和心理健康。</view>
					<view @click="goZN" class="nav-btn shadow bg-index2">进入</view>
				</view>
				<view class="kite-classify-cell shadow">
					<view class="nav-li bg-index2">
						<view class="nav-name">五音疗疾</view>
					</view>
					<view class="nav-content">利用（宫、商、角、徵、羽）治疗身心疾病，调和身心。</view>
					<view @click="goother" class="nav-btn shadow bg-index2">进入</view>
				</view>
				
			</scroll-view>
		</view>
	<!-- 心理干预 -->
	<view class="cu-bar bg-white margin-top-xs">
		<view class="action sub-title">
			<text class="text-xl text-bold text-blue text-shadow">医务人员疑惑解答</text>
			<text class="text-ABC text-blue">advice</text>
		</view>
	<!-- 	<view class="action" @click="goAdvice">
			<text class="text-lg text-grey text-shadow">更多</text>
		</view> -->
	</view>
	
	<view class="skill-sequence-panel-content-wrapper">
		<!--左边虚化-->
		<view class="hide-content-box hide-content-box-left"></view>
		<!--右边虚化-->
		<view class="hide-content-box hide-content-box-right"></view>
		
		<view class="problem-cell shadow-effect" v-for="(item, index) in problem" :key="index">
			
		    <view class="problem-description">
		      <view class="problem-time">您的问题：{{ item.evaluate_text }}</view>
		    </view>
		    <view class="problem-description">询问时间：{{ item.evaluate_time }}</view>
		    <view v-if="item.answer" @click="showAnswer(item.answer)" class="reply-button shadow-effect color-primary">查看回复</view>
			<view v-else @click="" class="reply-button1 shadow-effect color-primary">暂无回复</view>
		  </view>
	</view>
		<view style="height: 140rpx;width: 1rpx;"></view>
	</view>
</template>

<script>
	import request from '@/common/request.js';
	import addTip from "../../components/wxcomponents/struggler-uniapp-add-tip/struggler-uniapp-add-tip.vue"
	export default {
		components: {
			addTip
		},
		data() {
			return {
				tip: "点击「添加小程序」，下次访问更便捷",
				duration: 1,
				
				scrollTop: 0,
				old: {
					scrollTop: 0
				},

				bannerList: [
					{
						imageUrl: 'http://xinli.g60health.com:8000/xinliimg/111.png',
					},
					{
						imageUrl: 'http://xinli.g60health.com:8000/xinliimg/111.png',
					},
					{
						imageUrl: 'http://xinli.g60health.com:8000/xinliimg/111.png',
					},
					{
						imageUrl: 'http://xinli.g60health.com:8000/xinliimg/111.png',
					}
				],
				categories: [{
					cuIcon: 'hotfill',
					color: 'red',
					badge: '5',
					mid: '2',
					name: '心理指导'
				}, {
					cuIcon: 'colorlens',
					color: 'orange',
					badge: 1,
					mid: '2',
					name: '心理指导'
				}, {
					cuIcon: 'goodsnewfill',
					color: 'yellow',
					badge: 12,
					mid: '2',
					name: '心理指导'
				}, {
					cuIcon: 'calendar',
					color: 'cyan',
					badge: 22,
					mid: '2',
					name: '心理指导'
				}],
				adviceList: [
					{
						title: '医生建议1',
						content: '这是医生建议的内容1',
					},
					{
						title: '医生建议2',
						content: '这是医生建议的内容2',
					}
				],
				projectList: [],
				problem:{}
			}
		},
		watch: {

		},
		mounted() {
			let identity_card1=uni.getStorageSync("identity_card")
			console.log(identity_card1)
			if(identity_card1==""){
			uni.navigateTo({
				url: '../me/login'
			});}
			let user_id=uni.getStorageSync("user_id");
			let requestData={"userid":user_id}
			uni.request({
			  url: `http://202.127.200.31:30010/user/problemlist`,
			  method: 'POST',
			  data: requestData,
			  header: {
			    'Content-Type': 'application/json'
			  },
			  success: (res) => {
			    console.log('提交成功:', res.data["problem_list"]);
				this.problem=res.data["problem_list"]
				this.problem=this.problem.slice().reverse();
			    // uni.showToast({
			    //   title: '即将重新登陆.',
			    //   icon: 'success',
			    //   duration: 3000
			    // });
			    // setTimeout(() => {
			    //   uni.navigateTo({
			    //     url: '../me/login'
			    //   });
			    // }, 1000);
			  },
			  fail: (err) => {
			    console.error('提交失败:', err);
			    uni.showToast({
			      title: '提交失败',
			      icon: 'none',
			      duration: 2000
			    });
			  }
			});
			console.log(this.projectList)
			// this.getData();
		},
		methods: {
			  showAnswer(answer) {
			      uni.showModal({
			        title: '回复内容',
			        content: answer,
			        showCancel: false, // 不显示取消按钮
			        confirmText: '确定'
			      });
			    },
			  
			
			// getData() {
			// 	console.log('数据加载')
			// 	let opts = {
			// 		url: '/json/advice.json', // 修改为通过代理访问医生建议数据
			// 		method: 'get'
			// 	};
			// 	uni.showLoading({
			// 		title: '加载中'
			// 	})
			// 	request.httpRequest(opts).then(res => {
			// 		console.log(res);
			// 		uni.hideLoading();
			// 		if(res.statusCode == 200){
			// 			this.adviceList = res.data.data;
			// 		}else{
						
			// 		}
			// 	});
			// },
			scroll: function(e) {
				console.log(e)
				this.old.scrollTop = e.detail.scrollTop
			},
			goCategorieslist: function(e) {
				// console.log(e.currentTarget.dataset.mid)
				if(e.currentTarget.dataset.mid == 1 ){
					
					uni.navigateTo({
						url: '../video'
					})
				}else if(e.currentTarget.dataset.mid == 2){
				uni.navigateTo({
						url: '../zhengnian/xinlilist'
				})
				}else if(e.currentTarget.dataset.mid == 3){
					uni.navigateTo({
						url: '../project/list'
					})
				}else if(e.currentTarget.dataset.mid == 4){
					uni.navigateTo({
					
						url: '../timeline?mid=' + e.currentTarget.dataset.mid
					})
				}
			},
			goProjectList(){
				uni.navigateTo({
					url: '../project/list'
				})
			},
			goProject(id){
				uni.navigateTo({
					url: '../project/project?proId='+id
				})
			},
			goAdvice(){
				uni.navigateTo({
					url: '/pages/advice/advice'
				})
			},
			goLB(){
				uni.navigateTo({
					url: '/pages/me/mentalTest/list3xl'
				})
			},
			goZN(){
				uni.navigateTo({
					url: '/pages/zhengnian/zhengnianvideo'
				})
			},
			goother(){
				uni.navigateTo({
					url: '/pages/zhengnian/othervideo'
				})
			}
			// go3cxl(){
			// 	uni.navigateTo({
			// 		url: '/pages/me/mentalTest/list3xl'
			// 	})
			// }
		}
	}
</script>

<style lang="scss" scoped>
	.problem-cell {
	    margin: 10px;
	  }
	  .problem-header {
	    background-color: #f2f2f2;
	    padding: 10px;
	    border-radius: 5px;
	  }
	  .problem-time {
	    font-size: 16px;
	  }
	  .problem-description {
	    margin-top: 5px;
	  }
	  .reply-button {
	    background-color: #55aaff;
	    color: white;
	    text-align: center;
	    padding: 10px 20px;
	    margin-top: 10px;
	    border-radius: 5px;
	  }
	  .reply-button1 {
	    background-color: #ff0000;
	    color: white;
	    text-align: center;
	    padding: 10px 20px;
	    margin-top: 10px;
	    border-radius: 5px;
	  }
	  .shadow-effect {
	    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
	  }
	  .color-primary {
	    // background-color: #55aaff;
	  }
	  .color-variant {
	    background-color: #f2f2f2;
	  }
	  
	  
	.swiper-box {
		flex: 1;
	}

	.swiper-item {
		height: 100%;
	}
	/*scroll-view外层*/
	.skill-sequence-panel-content-wrapper {
		position: relative;
		white-space: nowrap;
		padding: 10rpx 0 10rpx 10rpx;
	}

	/*左右渐变遮罩*/
	.hide-content-box {
		position: absolute;
		top: 0;
		height: 100%;
		width: 10px;
		z-index: 2;
	}

	.hide-content-box-left {
		left: 0;
		background-image: linear-gradient(to left, rgba(255, 255, 255, 0), #f3f3f3 60%);
	}

	.hide-content-box-right {
		right: 0;
		background-image: linear-gradient(to right, rgba(255, 255, 255, 0), #f3f3f3 60%);
	}

	.kite-classify-scroll {
		width: 100%;
		height: 380rpx;
		overflow: hidden;
		white-space: nowrap;
	}

	.kite-classify-cell {
		display: inline-block;
		width: 280rpx;
		height: 370rpx;
		margin-right: 20rpx;
		background-color: #FFFFFF;
		border-radius: 10rpx;
		overflow: hidden;
		box-shadow: 2px 2px 3px rgba(26, 26, 26, 0.2);
	}

	.nav-li {
		padding: 40rpx 30rpx;
		width: 100%;
		background-image: url(https://s1.ax1x.com/2020/06/27/NyU04x.png);
		background-size: cover;
		background-position: center;
		position: relative;
		z-index: 1;
	}

	.nav-name {
		font-size: 28upx;
		text-transform: Capitalize;
		margin-top: 20upx;
		position: relative;
	}

	.nav-name::before {
		content: "";
		position: absolute;
		display: block;
		width: 40rpx;
		height: 6rpx;
		background: #fff;
		bottom: 0;
		right: 0;
		opacity: 0.5;
	}

	.nav-name::after {
		content: "";
		position: absolute;
		display: block;
		width: 100rpx;
		height: 1px;
		background: #fff;
		bottom: 0;
		right: 40rpx;
		opacity: 0.3;
	}

	.nav-content {
		width: 100%;
		padding: 15rpx;
		display: inline-block;
		overflow-wrap: break-word;
		white-space: normal;
	}

	.nav-btn {
		width: 200rpx;
		height: 60rpx;
		margin: 8rpx auto;
		text-align: center;
		line-height: 60rpx;
		border-radius: 10rpx;
	}

	.bg-index1 {
		background-color: orangered;
		color: #fff;
	}

	.bg-index2 {
		background-color: #954FF6;
		color: #fff;
	}

	.bg-index3 {
		background-color: #5177EE;
		color: #fff;
	}

	.bg-index4 {
		background-color: #F49A02;
		color: #fff;
	}

	.bg-index5 {
		background-color: #FF4F94;
		color: #fff;
	}

	.bg-index6 {
		background-color: #7FD02B;
		color: #fff;
	}

	.item-name {
		margin-bottom: 15rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		overflow: hidden;
	}
</style>